package com.godman.liu.loggingdemo.controller;

import com.google.gson.Gson;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
public class RootController {

    @GetMapping(value = "/")
    public String getMethod(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){
        Map<String,String[]> params = httpServletRequest.getParameterMap();
        System.out.println("RootController:"+new Gson().toJson(params));
        return "我是根结果111";
    }

    @PostMapping(value = "/")
    public String postMethod(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){
        Map<String,String[]> params = httpServletRequest.getParameterMap();
        System.out.println("RootController:"+new Gson().toJson(params));
        return "我是根结果22222";
    }
}
